<style>
    .layui-form-label {
        float: left;
        display: block;
        padding: 9px 15px;
        width: 120PX;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }
    .layui-input-block {
        margin-left: 150px;
        min-height: 36px;
    }
</style>
<div class="layui-fluid layui-anim website-anim-up" id="website-class-checkInfo" lay-title="审核信息">
    <div class="layui-row layui-col-space8 website-container">
        <div class="layui-col-md12 layui-col-sm12 layui-col-xs12">
            <form class="layui-form" lay-filter="class-apply-add-form">
                <input type="hidden" name="declareId" th:value="${declareId}">
                <div class="layui-card" id="client-user-info">
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <label class="layui-form-label website-form-item-require">审核结果</label>
                            <div class="layui-input-block">
                                <input type="radio" name="statusTypeCode" lay-filter="applyRadio" value="info_passed" title="通过" checked="">
                                <input type="radio" name="statusTypeCode" lay-filter="applyRadio" value="info_failed" title="不通过">
                            </div>
                        </div>
                        <div class="layui-row" id="checkResult">
                            <div class="layui-inline layui-col-md12">
                                <label class="layui-form-label website-form-item-require">审核不通过的原因</label>
                                <div class="layui-input-block">
                                    <textarea id="titleResult" class="layui-textarea" name="checkResult" placeholder="请输入内容，限制 500 字" autocomplete="off"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card-footer">
                            <button type="submit" class="layui-btn" lay-submit="" lay-filter="checkInfo">审核提交</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script data-th-inline="none" type="text/javascript">
    layui.use(['jquery', 'form', 'table', 'website'], function () {
        var $ = layui.jquery,
                laydate = layui.laydate,
                website = layui.website,
                form = layui.form,
                table = layui.table,
                view = layui.view;
        // 重新渲染 form否则不会显示下拉框
        $("#checkResult").css("display", "none");
        form.render();
        form.on('submit(checkInfo)', function(data){
            if(data.field.statusTypeCode=='info_failed'&& (data.field.checkResult==""||data.field.checkResult==null)){
                website.alert.error('审核不通过的原因不能为空');
                return false;
            }
            website.post(ctx + 'declareEntrust/checkInfo/commit', data.field, function () {
                layer.closeAll();
                website.alert.success('操作成功');
                $('#website-declareEntrust').find('#query').click();
            });
            return false;
        });
         form.on('radio(applyRadio)', function(data){
            if(data.value == 'info_failed'){
                $("#checkResult").css("display", "block");

            } else {
                $("#checkResult").css("display", "none");
                $("#titleResult").val("");
            }
        });

    })


</script>